<table>
    <tr class = "caption">
    <td>Rank</td>
    <td>Name</td>
    <td>Solved</td>
    <td>Total Time</td>
    <%@problems.each do |p|%>
    <td> <%= p.name%> </td>
    <% end%>
    <td>Attempts</td>
    
    </tr>
    <% rank = 1%>
    <% 0.upto @results.size-1 do |i|%>
      <tr><td> <%= rank%> </td>
      <% rank += 1 if(i < @results.size()-1 and (@results[i][1][:all] != @results[i+1][1][:all] or @results[i][1][:time] != @results[i+1][1][:time]))%>
      <td><%= @results[i][0]%></td>    
      <td><%= @results[i][1][:all]%></td>
      <td><%= @results[i][1][:time]%></td>
      
      <%@problems.each do |p|%>
      <td> <%= @results[i][1][p.problem_id].gsub(/\n/,'<br>')%> </td>
      <% end%>
      <td><%= "#{@results[i][1][:all]}/#{@results[i][1][:attempts]}"%></td>
      </tr>
    <% end%>
</table>

